/*
 * FuzzyValue.cpp
 *
 *  Created on: 08-01-2011
 *      Author: Piotr
 */

#include "AI/fuzzy/FuzzyValue.hpp"
#include "utils/MathUtils.hpp"
#include "AI/fuzzy/FuzzyUtils.hpp"

FuzzyValue::FuzzyValue()
{
	value = FuzzyUtils::NOT_MEMBER;
}

FuzzyValue::FuzzyValue(float value)
{
	this->value = value;
}

float FuzzyValue::getFloatValue() const
{
	return value;
}

FuzzyValue FuzzyValue::operator-() const
{
	return FuzzyValue(FuzzyUtils::fuzzyNot(value));
}

FuzzyValue FuzzyValue::operator+(const FuzzyValue& other) const
{
	return FuzzyValue(FuzzyUtils::fuzzyOr(value, other.value));
}

FuzzyValue FuzzyValue::operator*(const FuzzyValue& other) const
{
	return FuzzyValue(FuzzyUtils::fuzzyAnd(value, other.value));
}

FuzzyValue& FuzzyValue::operator+=(const FuzzyValue& other)
{
	value = FuzzyUtils::fuzzyOr(value, other.value);
	return *this;
}

FuzzyValue& FuzzyValue::operator*=(const FuzzyValue& other)
{
	value = FuzzyUtils::fuzzyAnd(value, other.value);
	return *this;
}

FuzzyValue& FuzzyValue::operator=(const FuzzyValue& other)
{
	if(this != &other)
	{
		value = other.value;
	}
	return *this;
}

bool FuzzyValue::operator==(const FuzzyValue& other) const
{
	return MathUtils::isEqual(value, other.value);
}

bool FuzzyValue::operator!=(const FuzzyValue& other) const
{
	return !(operator ==(other));
}
